package com.huangkailong.designpattern.delegate;

import java.util.HashMap;
import java.util.Map;

/**
 * 领导.
 *
 * @author huangkl
 * @since 1.0.0
 */
public class Leader implements Employee {
    private final Map<String, Employee> employees;

    public Leader() {
        this.employees = new HashMap<>();
        Programmer programmer = new Programmer();
        this.employees.put("程序", programmer);
        Designer designer = new Designer();
        this.employees.put("海报", designer);
    }

    @Override
    public void work(String something) {
        if (!employees.containsKey(something)) {
            System.out.println("找不到合适的人干" + something);
            return;
        }
        employees.get(something).work(something);
    }
}
